﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        static void TestEvent()
        {
            Console.WriteLine("test event");
        }

        static void TestDelegate()
        {
            Console.WriteLine("test delegate");
        }

        static void Main(string[] args)
        {
            MyClass myclass = new MyClass();
            myclass.WorkCompletedDelegate += TestDelegate; myclass.WorkCompletedDelegate += TestDelegate;

            myclass.WorkCompleted += TestEvent;
            myclass.Fire();
            myclass.WorkCompletedDelegate();


             
            Console.Read();
        }
    }

    class MyClass
    {
        public delegate void CompletedEventHandler();

        public event CompletedEventHandler WorkCompleted;
        public CompletedEventHandler WorkCompletedDelegate;

        public void Fire()
        {
            if (this.WorkCompleted != null)
            {
                this.WorkCompleted();
            }

            if (this.WorkCompletedDelegate != null)
            {
                this.WorkCompletedDelegate();
            }
        }
    }
}
